package com.spica.platform.base.feign.fallback;

import com.spica.platform.base.feign.AsyncUserFeignClient;
import com.spica.platform.base.model.LoginAppUser;
import com.spica.platform.base.model.ResponseEntity;
import com.spica.platform.base.model.SysUser;
import lombok.extern.slf4j.Slf4j;
import reactivefeign.FallbackFactory;
import reactor.core.publisher.Mono;

/**
 * UserFeignClient降级工场
 */
@Slf4j
public class AsyncUserFeignClientFallbackFactory implements FallbackFactory<AsyncUserFeignClient> {
	@Override
	public AsyncUserFeignClient apply(Throwable throwable) {
		return new AsyncUserFeignClient() {
			@Override
			public Mono<ResponseEntity<SysUser>> findSysUserByUsername(String username) {
				log.error("通过用户名查询用户异常:{}", username, throwable);
				return null;
			}

			@Override
			public Mono<ResponseEntity<LoginAppUser>> findLoginAppUserByUsername(String username) {
				log.error("通过用户名查询用户异常:{}", username, throwable);
				return null;
			}

			@Override
			public Mono<ResponseEntity<LoginAppUser>> findLoginAppUserByMobile(String mobile) {
				log.error("通过手机号查询用户异常:{}", mobile, throwable);
				return null;
			}

			@Override
			public Mono<ResponseEntity<LoginAppUser>> findLoginAppUserByUserId(String userId) {
				log.error("通过userId查询用户异常:{}", userId, throwable);
				return null;
			}

			@Override
			public Mono<ResponseEntity<LoginAppUser>> findLoginAppUserByOpenId(String openId) {
				log.error("通过openId查询用户异常:{}", openId, throwable);
				return null;
			}
		};
	}

}
